package com.lifeng.patterns.spring.controller;

import com.lifeng.patterns.spring.AnimalFactoryBean;
import com.lifeng.patterns.spring.ApplicationContextUtils;
import com.lifeng.patterns.spring.SysUser;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @description:
 * @author: lifeng
 * @create: 2020/9/21 15:55
 */
@RestController
public class SpringController {

    @RequestMapping("/spirng1")
    public Object test1(){
        SpringController controller = ApplicationContextUtils.applicationContext.getBean(SpringController.class);
        SysUser sysUser = ApplicationContextUtils.applicationContext.getBean(SysUser.class);
        AnimalFactoryBean animalFactoryBean = ApplicationContextUtils.applicationContext.getBean(AnimalFactoryBean.class);
        try {
            SysUser sysUser1 = animalFactoryBean.getObject();
        } catch (Exception exception) {
            exception.printStackTrace();
        }
        return controller;
    }
}
